odoo.define('web_optimize.AttachmentPreview', function (require) {
"use strict";


var registry = require('web.field_registry');
var PreviewHelper = require('web_optimize.PreviewHelper');


var FormRelational = require('web.relational_fields');



var FieldMany2ManyBinaryMultiFilesPreview = FormRelational.FieldMany2ManyBinaryMultiFiles.extend({
    events:  _.extend({}, FormRelational.FieldMany2ManyBinaryMultiFiles.prototype.events, {
        "click .o_attachment .o_attachment_wrap .o_image_box": "_onPreview",
    }),
    _onPreview: function (e) {
        e.preventDefault();
        e.stopPropagation();
        var fileId = parseInt($(e.currentTarget).attr('data-id'));
        PreviewHelper.createAttachmentPreview(fileId);
    }
});

registry.add('many2many_binary_preview', FieldMany2ManyBinaryMultiFilesPreview);

});
